package com.shuoyue.ycgk.ui.recruitment.newsinfo;

import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.base.ListWithPage;
import com.shuoyue.ycgk.entity.JobInfo;
import com.shuoyue.ycgk.entity.RecruitmentItem;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;
import com.shuoyue.ycgk.ui.recruitment.job.JobContract;

import io.reactivex.Observable;

public interface NoticeListContact {
    interface View extends BaseView {

        void setList(ListWithPage<RecruitmentItem> list);
    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void getRecurimentList(Integer modelId, int page ) {
            apply(model.getRecurimentList(modelId, page ))
                    .subscribe(new ApiSubscriber<Optional<ListWithPage<RecruitmentItem>>>(mView, this) {
                        @Override
                        public void onNext(Optional<ListWithPage<RecruitmentItem>> data) {
                            super.onNext(data);
                            mView.setList(data.getIncludeNull());
                        }
                    });
        }
    }

    class Model {

        public Observable<BaseResult<ListWithPage<RecruitmentItem>>> getRecurimentList(Integer modelId, int page ) {
            return RetrofitClient.getInstance().getApi().getRecurimentList(null, page );
        }
    }
}
